package com.example.demo;

import ag.AGContext;
import ag.AGEngine;
import ag.AGResource;
import ag.AGView;
import ag.ui.AGButton;
import ag.ui.AGControl;
import ag.ui.IAGEventHandler;
import android.graphics.RectF;

public class AudioView1 extends AGView {
	public AudioView1(){
		AGEngine.getInstance().getADI().playMusic("bg1");
		
		AGButton btnPlay01 = new AGButton(new RectF(400,400,600,450), AGResource.getInstance().getTexture("tf"));
		btnPlay01.addClickEvent(new BtnPlayer01Click());
		this.addControl(btnPlay01);

		AGButton btnPlay02 = new AGButton(new RectF(400,600,600,650), AGResource.getInstance().getTexture("tf"));
		btnPlay02.addClickEvent(new BtnPlayer02Click());
		this.addControl(btnPlay02);

		AGButton btnPlay03 = new AGButton(new RectF(600,300,800,350), AGResource.getInstance().getTexture("tf"));
		btnPlay03.addClickEvent(new BtnPlayer03Click());
		this.addControl(btnPlay03);
	}

	@Override
	public void onUpdate(AGContext context) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void onRender(AGContext context) {
		// TODO Auto-generated method stub
		
	}
	
	@Override
	protected void onClose(){
		AGEngine.getInstance().getADI().stopMusic();
	}

	class BtnPlayer01Click implements IAGEventHandler{
		@Override
		public void onHandle(AGControl control) {
			AGEngine.getInstance().getADI().playMusic("bg1");
		}
	}

	class BtnPlayer02Click implements IAGEventHandler{
		@Override
		public void onHandle(AGControl control) {
			AGEngine.getInstance().getADI().playMusic("bg2");
		}
	}
	
	class BtnPlayer03Click implements IAGEventHandler{
		@Override
		public void onHandle(AGControl control) {
			AGEngine.getInstance().getADI().playSound("btnclick");
		}
	}
}
